﻿@using OSBIDE.Analytics.Web.Models.ViewModels.CommentAnalyzer
@using OSBIDE.Library.Models
@model IndexViewModel
@{
    ViewBag.Title = "Index";
    int rowCount = 0;
}
@section header
{
    <style type="text/css">
        #activityTable, #activityTable th, #activityTable td
        {
            border: 1px solid black;
            padding:3px;
        }

    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#activityTable").tablesorter();
        }
);
    </script>
}
@section scripts
{
    @Scripts.Render("~/bundles/tablesorter")
}
<h2>Students in @Model.Course.Name</h2>
<table id="activityTable" class="tablesorter">
    <thead>
        <tr>
            <th>#</th>
            <th>OSBIDE ID</th>
            <th>Student ID</th>
            <th>Last Name</th>
            <th>First Name</th>
            <th>Total Social Activity</th>
            <th>Number of Posts</th>
            <th>Number of Replies</th>
            <th>Number of document saves</th>
        </tr>
    </thead>
    <tbody>
        @foreach (OsbideUser user in Model.Users)
        {
            rowCount++;
            if (Model.PostsByUser.ContainsKey(user.Id) == false)
            {
                Model.PostsByUser.Add(user.Id, 0);
            }
            if (Model.RepliesByUser.ContainsKey(user.Id) == false)
            {
                Model.RepliesByUser.Add(user.Id, 0);
            }
            if (Model.SavesByUser.ContainsKey(user.Id) == false)
            {
                Model.SavesByUser.Add(user.Id, 0);
            }
            <tr>
                <td>@rowCount</td>
                <td>
                    @Html.ActionLink(user.Id.ToString(), "Student", new { id = user.Id})
                </td>
                <td>
                    @user.InstitutionId
                </td>
                <td>
                    @user.LastName
                </td>
                <td>
                    @user.FirstName
                </td>
                <td>
                    @(Model.PostsByUser[user.Id] + Model.RepliesByUser[user.Id])
                </td>
                <td>
                    @Model.PostsByUser[user.Id]
                </td>
                <td>
                    @Model.RepliesByUser[user.Id]
                </td>
                <td>
                    @Model.SavesByUser[user.Id]
                </td>
            </tr>
        }
    </tbody>
</table>